package com.neuedu.mblog.common;

import lombok.Data;

/**
 * 项目：vue-ifs
 * 创建时间：  2022-03-11   10:00
 * 作者 :jshand
 * 描述 :
 */
@Data
public class CommonResult {
    private Integer code; // 200 404 500
    private String msg;    //错误消息

    private Object data;

    private CommonResult(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static CommonResult success(Object data){
        return new CommonResult(200,"",data);
    }

    public static CommonResult failed(){
        return new CommonResult(500,"网络请求失败",null);
    }
    public static CommonResult failed(String msg){
        return new CommonResult(500,msg,null);
    }

    public static CommonResult notFound(){
        return new CommonResult(404,"请求路径不存在",null);
    }

    public static CommonResult noPremisse(){
        return new CommonResult(403,"",null);
    }


    /**
     * 通用的返回结果
     * @param code
     * @param msg
     * @param data
     * @return
     */
    public static CommonResult failed(Integer code ,String msg,Object data){
        return new CommonResult(code,msg,data);
    }

}
